const schedule = require('node-schedule');
const axios = require('axios');

function run() {
  axios({
    url: 'http://59.110.10.239:8083/api/gitlab/recentBranches',
    // url: 'http://localhost:3000/api/gitlab/recentBranches',
    method: 'post',
    headers: { 'Content-type': 'application/json' },
  });
}

// const rule = new schedule.RecurrenceRule();
// const date = new Date();
// date.setSeconds(date.getSeconds() + 5);
// rule.hour = date.getHours();
// rule.minute = date.getMinutes();
// rule.second = date.getSeconds();

// schedule.scheduleJob(rule, async () => {
//   run();
// });

// 定义每周一、二、三、四、五的上午9点半触发
// const morningJob = schedule.scheduleJob('30 9 * * 1-5', function () {
//   console.log('上午9点半触发');
//   run();
// });

// // 定义每周一、二、三、四、五的下午6点触发
const eveningJob = schedule.scheduleJob('0 18 * * 1-5', function () {
  console.log('下午6点触发');
  run();
});
